
// #/~java-properties
sammy.get(/^#\/(~java-properties)$/, function(context) {
	var content_element = $('#content');

	content_element.html('<div id="java-properties"></div>');

	$.ajax({
		url : app.config.solr_path + '/admin/info/properties?wt=json',
		dataType : 'json',
		context : $('#java-properties', content_element),
		beforeSend : function(xhr, settings) {
			this.html('<div class="loader">Loading ...</div>');
		},
		success : function(response, text_status, xhr) {
			var system_properties = response['system.properties'];
			var properties_data = {};
			var properties_content = [];
			var properties_order = [];

			var workaround = xhr.responseText.match(/"(line\.separator)"\s*:\s*"(.+?)"/);
			if (workaround && workaround[2]) {
				system_properties[workaround[1]] = workaround[2];
			}

			for ( var key in system_properties) {
				var displayed_key = key.replace(/\./g, '.&#8203;');
				var displayed_value = [ system_properties[key] ];
				var item_class = 'clearfix';

				if (-1 !== key.indexOf('.path') || -1 !== key.indexOf('.dirs')) {
					displayed_value = system_properties[key].split(system_properties['path.separator']);
					if (1 < displayed_value.length) {
						item_class += ' multi';
					}
				}

				var item_content = '<li><dl class="' + item_class + '">' + "\n" + '<dt>' + displayed_key.esc() + '</dt>' + "\n";

				for ( var i in displayed_value) {
					item_content += '<dd>' + displayed_value[i].esc() + '</dd>' + "\n";
				}

				item_content += '</dl></li>';

				properties_data[key] = item_content;
				properties_order.push(key);
			}

			properties_order.sort();
			for ( var i in properties_order) {
				properties_content.push(properties_data[properties_order[i]]);
			}

			this.html('<ul>' + properties_content.join("\n") + '</ul>');

			$('li:odd', this).addClass('odd');

			$('.multi dd:odd', this).addClass('odd');
		},
		error : function(xhr, text_status, error_thrown) {},
		complete : function(xhr, text_status) {}
	});
});